package com.archives.blog.common.interceptor;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.springframework.web.servlet.handler.HandlerInterceptorAdapter;

import com.archives.blog.common.domain.entity.Admin;
import com.archives.blog.common.utils.SessionUtil;

/**
 * 拦截未登录的用户信息
 * 
 * @author chh
 *
 */
public class ERPAdminSecurityInterceptor extends HandlerInterceptorAdapter {

	@Override
	public boolean preHandle(HttpServletRequest request, HttpServletResponse response, Object handler)
			throws Exception {
		Admin obj = SessionUtil.getLoginAdmin(request);
        if (obj == null) {
            response.sendRedirect(request.getContextPath() + "/erp/login");
            return false;
        }
        return true;
	}

}
